package com.roc.jpamysql;

import com.roc.jpamysql.dao.UserMapper;
import com.roc.jpamysql.model.T1;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.annotation.Resource;
import java.util.List;


@SpringBootTest
public class JpaMysql {

    @Resource
    private JdbcTemplate jdbcTemplate;

    @Resource
    UserMapper userMapper;

    @Test
    public void test() {
        String sql = "select * from t1";
        List<T1> id = jdbcTemplate.query(sql, (rs, rowNum) -> {
            T1 t1 = new T1();
            t1.setId(rs.getInt("id"));
            return t1;
        });
        System.out.println(id);
    }

    @Test
    public void testMapper(){
        List<T1> t1 = userMapper.getT1();
        System.out.println(t1);

    }

    @Test
    public void testXMLMapper(){
        // test-class 没有加载 resource
        Integer t1 = userMapper.getUser();
        System.out.println(t1);
    }
}
